package com.zzzn.rhtx.controller;

import com.zzzn.rhtx.entity.*;
import com.zzzn.rhtx.service.CallingStartEndService;
import com.zzzn.rhtx.service.RhtxClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 通话、视频、会议
 * @auther Yuzhong.Guo
 * @date 2022/11/1 15:11
 */
@RequestMapping(value = "/idispatch")
@RestController
public class CallingController {

    @Autowired
    private RhtxClient rhtxClient;

    @Autowired
    private CallingStartEndService callingStartEndService;

    /**
     * 1对多语音，视频
     * @param requestDo
     * @return
     */
    @PostMapping("/makecall/more")
    public CallMoreResultVo makeCallPoll(@RequestBody OneToMoreCallRequestDTO requestDo) {
        return callingStartEndService.startPollCall(requestDo);
    }

    /**
     * 加入会议
     * @param requestDo
     * @return
     */
    @PostMapping("/joinmeetcall")
    public CallMoreResultVo clearCall(@RequestBody JoinMeetDTO requestDo) {
        return callingStartEndService.joinMeetCall(requestDo);
    }


    /**
     * 结束1对多语音，视频
     * @returnc
     */
    @PostMapping("/endmorecall")
    public BaseResult endPollCall() {
        return callingStartEndService.endMoreCall();
    }

    /**
     * 呼叫控制/单呼
     *
     * "callType": " audio ",   或者video视频通话
     * @param requestDo
     * @return
     */
    @PostMapping("/makecall")
    public CallOneResultVo makeCall(@RequestBody OneToOneCallRequestDTO requestDo) {
        return callingStartEndService.makeCall(requestDo);
    }

    /**
     * 呼叫控制/挂断
     *
     * @return
     */
    @PostMapping("/clearcall")
    public BaseResult clearCall() {
        return callingStartEndService.clearCall();
    }


    /**
     * 轮询拉取消息
     * @returnc
     */
    @GetMapping("/pollmessage")
    public MakeCallPollResponse pollMessage() {
        return rhtxClient.poll();
    }


    /**
     * 通过对应通话id查询通话录音
     * @param requestDo
     * @return
     */
    @PostMapping("/getspecifiedrec")
    public BaseResult getSpecifiedRec(@RequestBody RecordRequestDo requestDo) {
        requestDo.getRequest().setType("GetSpecifiedRec");
        return rhtxClient.getSpecifiedRec(requestDo);
    }


    /**
     * 同步获取通话记录
     * @param requestDo
     * @return
     */
    @PostMapping("/callrecord")
    public CallRecordResponse callRecord(@RequestBody CallRecordRequestDo requestDo) {
        return rhtxClient.callRecord(requestDo);
    }

    /**
     * 创建会议
     * @param requestDo
     * @return
     */
    @PostMapping("/createmeet")
    public MakeCallResponse getSpecifiedRec(@RequestBody CreateMeetingRequestDo requestDo) {
        requestDo.getRequest().setType("CreateMeet");
        return rhtxClient.createMeet(requestDo);
    }

    /**
     * 结束会议
     * @param requestDo
     * @return
     */
    @PostMapping("/endmeet")
    public BaseResult getSpecifiedRec(@RequestBody EndMeetingRequestDo requestDo) {
        requestDo.getRequest().setType("EndMeet");
        return rhtxClient.endMeet(requestDo);
    }


    /**
     * 修改会议
     * @param requestDo
     * @return
     */
    @PostMapping("/updatemeet")
    public BaseResult modifyMeet(@RequestBody UpdateMeetingRequestDo requestDo) {
        requestDo.getRequest().setType("ModifyMeet");
        return rhtxClient.modifyMeet(requestDo);
    }

    /**
     * 会议发言
     * @param requestDo
     * @return
     */
    @PostMapping("/meetallowspeak")
    public BaseResult meetAllowSpeak(@RequestBody MeetingSpeakRequestDo requestDo) {
        requestDo.getRequest().setType("MeetAllowSpeak");
        return rhtxClient.meetAllowSpeak(requestDo);
    }

    /**
     * 会议禁言
     * @param requestDo
     * @return
     */
    @PostMapping("/meetbanspeak")
    public BaseResult meetBanSpeak(@RequestBody MeetingSpeakRequestDo requestDo) {
        requestDo.getRequest().setType("MeetBanSpeak");
        return rhtxClient.meetBanSpeak(requestDo);
    }

    /**
     * 会议踢出
     * @param requestDo
     * @return
     */
    @PostMapping("/meetkick")
    public BaseResult meetKick(@RequestBody MeetingSpeakRequestDo requestDo) {
        requestDo.getRequest().setType("MeetKick");
        return rhtxClient.meetKick(requestDo);
    }


}
